/**
 * 查看供抢页面
 */
var basePage = require('../../../common/BasePage');
Page({
  behaviors: [basePage],
  data: {
    // order_id:0,
    /**供应商列表 */
    supplierArr:[]
  },
  onLoad: function (options) {
    console.log("供抢列表",options);
    if(!options.order_id){
      wx.showToast({
        title: '缺少订单信息',
        icon:'none'
      })
      return wx.navigateBack({
        delta: 1,
      })
     
    }
    // this.data.order_id=options.order_id;
    //获取供应商
    this.request({
      url: this.data.host + '/home/buy/my/supplier?limit=100&order_id='+options.order_id
    }, res => {
       console.log("/home/buy/my/supplier", res);
       let supplierArr=res.data.supplier;
       supplierArr.map(val=>{
        val.thumb = this.get_thumb(val.logo);
       })
       
      this.setData({
        supplierArr
      })
      console.log("supplierArr",supplierArr)
    }); 
  },
  /**锁定供应商 */
  select_click(e){
    let supplier=this.data.supplierArr[e.currentTarget.dataset.index];
    this.request({
      url: this.data.host + '/home/buy/my/select',
      method: "POST",
                data: {
                    order_id: supplier.order_id,
                    supplier_id:supplier.supplier_id
                }
    }, res => {
       console.log("select", res);
      wx.showToast({
        title: '锁定成功',
        icon:'none'
      })
      wx.navigateBack({
        delta: 1,
      })
    }); 
  },
  onReady: function () {

  }
})